package com.qf.smartplatform.controller;

import com.qf.smartplatform.dto.R;
import com.qf.smartplatform.pojo.SysScene;
import com.qf.smartplatform.service.SysSceneService;
import com.qf.smartplatform.valigroup.delete;
import com.qf.smartplatform.valigroup.insert;
import com.qf.smartplatform.valigroup.select;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/scence")
public class SceneController {
    private SysSceneService sysSceneService;
    @Autowired
    public void setSysSceneService(SysSceneService sysSceneService) {
        this.sysSceneService = sysSceneService;
    }

    @PostMapping("/add")
    public R addScene(@Validated(insert.class) @RequestBody  SysScene sysScene){

        return R.OK(sysSceneService.addScene(sysScene));
    }
    @PostMapping("/delete")
    public R deleteScene(@Validated(delete.class) @Param("sceneId") String sceneId){
        return R.OK(sysSceneService.deleteSceneById(sceneId));
    }
    @PostMapping("/update")
    public R updateScene(@Validated(insert.class) @RequestBody  SysScene sysScene){
        return R.OK(sysSceneService.updateScene(sysScene));
    }
    @PostMapping("/select")
    public R findById(@Validated(select.class)  @Param("sceneId") Long sceneId){
        return R.OK(sysSceneService.findById(sceneId));
    }
    @PostMapping("/selectAll")
    public R findAllByUser(){
        return R.OK(sysSceneService.findAllByUSer());
    }
}
